package cn.imvc.app.models;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.stereotype.Service;

import cn.imvc.app.entities.Brand;
import cn.imvc.app.entities.BrandGoodsClass;
import cn.imvc.app.repositories.BrandGoodsClassRepository;
import cn.imvc.app.repositories.BrandRepository;

@Service
public class BrandModelImpl implements BrandModel {
	@Autowired
	BrandRepository brandRepository;
	@Resource
	private BrandGoodsClassRepository brandGoodsClassRepository;

	public Brand getBrand(Integer brandId) {
		return brandRepository.getOne(brandId);
	}

	public List<Brand> getAllBrand() {
		//Order order = new Order(Sort.Direction.ASC, "sort");
		//Sort sort = new Sort(order);
		//return brandRepository.findAll(sort);
		return brandRepository.findByIsShowOrderBySort((byte)1);
	}

	public List<BrandGoodsClass> getAllBrandGoodsClass() {
		return brandGoodsClassRepository.findAll();
	}

}
